package cn.cutie.clot.mq.model;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.List;

/**
 * @Description:
 * @Author: Cutie
 * @CreateDate: 2024/7/10 10:44
 * @Version: 0.0.1
 */
@Data
@AllArgsConstructor
public class Result<T> {
    private int code; // 1==success -==fail
    private T data;

    public static Result<String> ok() {
        return new Result(1, "OK");
    }

    public static Result<String> ok(String msg) {
        return new Result(1, msg);
    }

    public static Result<ClotMessage<?>> msg(String msg) {
        return new Result<>(1, ClotMessage.create(msg, null));
    }

    public static Result<ClotMessage<?>> msg(ClotMessage<?> msg) {
        return new Result<>(1, msg);
    }

    public static Result<List<ClotMessage<?>>> msg(List<ClotMessage<?>> batch) {
        return new Result<>(1, batch);
    }
}
